package com.culture.java.online.education.platform.business.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.culture.java.online.education.platform.business.demo.dao.StudentDao;
import com.culture.java.online.education.platform.business.demo.service.StudentService;
import com.culture.java.online.education.platform.data.demo.entity.Student;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.stereotype.Service;

@Service
public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> implements StudentService {

    @Override
    public boolean save(Student entity) {
        entity.setPassword(BCrypt.hashpw(entity.getPassword(), BCrypt.gensalt()));
        return super.save(entity);
    }

    @Override
    public boolean updateById(Student entity) {
        entity.setPassword(BCrypt.hashpw(entity.getPassword(), BCrypt.gensalt()));
        return super.updateById(entity);
    }

}
